public int maxNumberOfBalloons(String text) {
    int[] word = new int[26];
    for (int i = 0; i < text.length(); i++) {
        char ch = text.charAt(i);
        word[ch - 'a']++;
    }
    int ans = Integer.MAX_VALUE;
    for (int i = 0; i < 26; i++) {
        if (i == 'b' - 'a' || i == 0 || i == 'n' - 'a') {
            ans = Math.min(ans, word[i]);
        }
        if (i == 'l' - 'a' || i == 'o' - 'a') {
            ans = Math.min(ans, word[i] / 2);
        }
    }
    return ans;
}